package com.miszczu.dao;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.miszczu.model.Accounttypes;
import com.miszczu.utils.CustomHibernateSupport;

@Repository
public class AccounttypesDaoImpl extends CustomHibernateSupport implements AccounttypesDao {

	public Accounttypes getAccountType(String type) {
		
		DetachedCriteria crit = DetachedCriteria.forClass(Accounttypes.class);
		crit.add(Restrictions.eq("accountType", type));
		
		List results = getHibernateTemplate().findByCriteria(crit);
		
		if(!results.isEmpty()) {
			return (Accounttypes) results.get(0);
		}
		
		return null;
	}

}
